import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'
// import Login from '../login.vue'
import Main from '../main.vue'
import Students from '../students.vue'
import Details from '../details.vue'
import Pass from '../password.vue'
import News from '../news.vue'
import Hospital from '../home.vue'
import Medicine from '../medicine.vue'
import Doctors from '../doctors.vue'
import Prescription from '../prescription.vue'
import Nonprescription from '../nonprescription.vue'
import Docs from '../docs.vue'
import Contract from '../contract.vue'
import Content from '../content.vue'

const routes = [

    { path: '/login', component: ()=>import('../login.vue') },
    { path: '/', redirect:'/login' },
    {
        path: '/main',
        component: Main,
        beforeEnter: (to, from) => {
            console.log(to.fullPath)
        },
        children: [
            { path: 'password', component: Pass },
            { path: 'news', component: News },
        ]
    },
    { path: '/students', component: Students ,alias:'/student'},
    {
        // path: '/details/:id', 
        path: '/details',
        component: Details,
        name: "detail",
        redirect: to => {
            // return { path:'/content/'+to.params.id} 
            return 'students'
        }
    },
    {
        path:'/content/:id',
        component:Content
    },
    {
        path: '/hospital',
        component: Hospital,
        children: [
            {
                path: 'medicine',
                components: {
                    aside: Medicine,
                    main: Prescription,
                }
            },
            {
                path: 'nonprescription',
                components: {
                    aside: Medicine,
                    main: Nonprescription,
                }
            },
            {
                path: 'doctors',
                components: {
                    aside: Doctors,
                    main: Docs,
                }
            },
            {
                path: 'contract',
                components: {
                    aside: Doctors,
                    main: Contract,
                }
            }

        ]
    }
]
const router = createRouter({
    history: createWebHashHistory(),
    routes,
})
router.beforeEach((to,from)=>{
    // console.log(to);
    if(to.fullPath!=="/login"){
        // return {path:'/login'}
    }
})
export default router;